var Checkin = require('./dal/checkin.js')

var routerApi = require('../../utils/routeString.js')(__filename, __dirname);

/**
 * params:isList uid offset limit orderby sort
 * 
 */

const getCkData = async function (req, res) {
    var body = req.body || req.query;

    let ck = new Checkin({ uid: body.uid });

    // 返回其中一个数据
    if (body.uid) {
        let results = await ck.select();
        return res.send({ code: 1, result: results[0] })
    }

    // 返回数据列表及注释、数量属性
    if (body.offset && body.limit) {
        let results = await ck.selectAll(null, body.offset, body.limit, body.orderby, body.sort);
        let comments = await ck.comments();
        let count = await ck.count();
        return res.send({ code: 1, results: results, comments: comments, count: count })
    }

}



server.get(routerApi, getCkData);

